public class Offer66 {
    public int[] constructArr(int[] a) {
        if (a.length==0) return new int[0];
        int[] result = new int[a.length];
        result[0] = 1;
        for (int i = 1; i < result.length; i++) {
            result[i] =result[i-1]*a[i-1];
        }
        int temp =1;
        for (int i = result.length-2; i >=0 ; i--) {
            temp *= a[i+1];
            result[i]*= temp;
        }
        return result;
    }
}
